关于ASP 一个简单的判断`迷惑。。。

来源:百度知道 编辑:UC知道 时间:2024/05/09 17:04:34
很简单的
cardnum 是 文本框读的数字
cardnum_ 是统计数据条数 反回的数字

不管是 cardnum 比 cardnum 大 ``小``还是相等。。。判断都会成立。。。

我巨汗。。。不可能啊?

<%
if cardnum > cardnum_ then
%>
<SCRIPT LANGUAGE=vbscript>
<!--
msgbox("该卡存货不足!<%=cardnum%>|<%=cardnum_%>")
window.location.href="javascript:history.back(1)"
-->
</SCRIPT>
<%
response.end
end if
%>
一剑你的答案不是原因所在

if Int(cardnum) > Int(cardnum_) then

最好先确定两个变量的输出值~~~~

因为你的vbscript脚本代码不在<% %>之内,所以脚本代码没有在服务器端执行而在客户端执行当然每次都会运行了。正确的方法应该是:
<%
if cardnum > cardnum_ then
response.write "<SCRIPT LANGUAGE=vbscript> "
response.write "<!-- "
....
response.write "</SCRIPT> "
response.end
end if
%>

最好不要用cardnum_之类的变量名,
“_”是用来连接分开在两行的语句用的